package com.pay.sdk.service.channel2;

import java.util.HashMap;

import com.pay.sdk.service.liquidation.MsBankTypeQuery;
import com.pay.sdk.service.liquidation.MsPay;
import com.pay.sdk.service.liquidation.MsPayQuery;
import com.pay.sdk.service.pay.MsBarPay;
import com.pay.sdk.service.pay.MsH5Pay;
import com.pay.sdk.service.pay.MsOrderSync;
import com.pay.sdk.service.pay.MsScanPay;
import com.pay.sdk.service.pay.MsScanPayQuery;

public class ChanneTwolPay {

	 /**
     * 单笔代付
     * @param user_order_no 用户订单号
     * @param amount  金额
     * @param account_type 账户类型
     * @param account_no 账号
     * @param account_name 开户名
     * @param id_type  证件类型
     * @param id  证件号
     * @param tel 电话号码
     * @param bank_code 银行编码
     * @return json格式结果，返回结果包含字段请参看文档
     */
    public static String payOther(String user_order_no,String amount,String account_type,String account_name,String account_no,String id_type,String id,String tel,String bank_code,String account_prop,String bank_type) {

        HashMap<String, String> params = new HashMap<String, String>();
        params.put("user_order_no", user_order_no);
        params.put("amount", amount);
        params.put("account_type", account_type);
        params.put("account_name", account_name);
        params.put("account_no", account_no);
        params.put("id_type", id_type);
        params.put("id", id);
        params.put("tel", tel);
        params.put("bank_code", bank_code);
        params.put("bank_type", bank_type);
        params.put("account_prop", account_prop);
        
        return new MsPay().exec(params);
    }
    
    /**
     * 代付查询
     * @param query_sn 查询交易流水
     * @param user_order_no 用户订单号 二选一
     * @return
     */
    public static String payOtherQuery(String query_sn,String user_order_no) {
        HashMap<String, String> params = new HashMap<String, String>();
        params.put("query_sn", query_sn);
        params.put("user_order_no",user_order_no);
        return new MsPayQuery().exec(params);
    }
    
    
    /**
     * 代付银行联行号查询
     * @param bank_code 银行编码
     * @param province  开户省份
     * @param city  开户城市
     * @param branch_name 开户网点关键字
     * @return
     */
    public static String bankTypeQuery(String bank_code,String province,String city,String branch_name) {
        HashMap<String, String> params = new HashMap<String, String>();
        params.put("bank_code", bank_code);
        params.put("province", province);
        params.put("city",city);
        params.put("branch_name", branch_name);
        return new MsBankTypeQuery().exec(params);
    }
    
    
    /**
	 * 扫码支付
	 * @param out_trade_no
	 * @param total_fee
	 * @param body
	 * @param device_info
	 * @param notify_url
	 * @param acquirer_type
	 * @param bank_card_limit
	 * @param time_expire
	 * @param attach
	 * @return
	 */
	public static String scanPay(String out_trade_no, String total_fee, String body, String device_info,
			String notify_url,String acquirer_type,String bank_card_limit,String time_expire,String attach) {
		  HashMap<String, String> params = new HashMap<String, String>();
	        params.put("out_trade_no", out_trade_no);
	        params.put("total_fee", total_fee);
	        params.put("body", body);
	        params.put("device_info", device_info);
	        params.put("notify_url", notify_url);
	        params.put("acquirer_type", acquirer_type);
	        params.put("bank_card_limit", bank_card_limit);
	        params.put("time_expire", time_expire);
	        params.put("attach", attach);
	        return new MsScanPay().exec(params);
	}
	/**
	 * H5支付（微信）
	 * @param out_trade_no
	 * @param total_fee
	 * @param body
	 * @param device_info
	 * @param notify_url
	 * @return
	 */
	public static String h5Pay(String out_trade_no, String total_fee, String body, String device_info,
			String notify_url,String acquirer_type,String bank_card_limit,String time_expire,String appId,String openid) {
		HashMap<String, String> params = new HashMap<String, String>();
		params.put("out_trade_no", out_trade_no);
		params.put("total_fee", total_fee);
		params.put("orderDesc", "测试商品描述");
		params.put("body", body);
		params.put("device_info", device_info);
		params.put("notify_url", notify_url);
		params.put("acquirer_type", acquirer_type);
		params.put("bank_card_limit", bank_card_limit);
		params.put("time_expire", time_expire);
		params.put("appId", appId);
		params.put("openid", openid);
		return new MsH5Pay().exec(params);
	}

	/**
	 * 支付结果查询
	 * @param out_trade_no
	 * @param transation_id
	 * @param out_transation_id
	 * @return
	 */
	public static String payQuery(String out_trade_no, String transation_id, String out_transation_id) {
		HashMap<String, String> params = new HashMap<String, String>();
	    params.put("out_trade_no", out_trade_no);
	    params.put("transation_id", transation_id);
	    params.put("out_transation_id", out_transation_id);
	    return new MsScanPayQuery().exec(params);
	}
	
	/**
	 * 条码支付
	 * @param out_trade_no
	 * @param total_fee
	 * @param body
	 * @param auth_code
	 * @param device_info
	 * @param acquirer_type
	 * @param bank_card_limit
	 * @param time_expire
	 * @param attach
	 * @return
	 */
	public static String barPay(String out_trade_no, String total_fee, String body, String auth_code,
			String device_info, String acquirer_type, String bank_card_limit, String time_expire,
			String attach) {
		HashMap<String, String> params = new HashMap<String, String>();
	    params.put("out_trade_no", out_trade_no);
	    params.put("total_fee", total_fee);
	    params.put("body", body);
	    params.put("auth_code", auth_code);
	    params.put("device_info", device_info);
	    params.put("acquirer_type", acquirer_type);
	    params.put("time_expire", time_expire);
	    params.put("bank_card_limit", bank_card_limit);
	    params.put("attach", attach);
	    return new MsBarPay().exec(params);
	}
	
	public static String orderSync(String transaction_id) {
		HashMap<String, String> params = new HashMap<String, String>();
	    params.put("transaction_id", transaction_id);
	    return new MsOrderSync().exec(params);
	}
	
}
